<template>
  <div>
    <p>{{$store.state.count}}</p>
    <p>{{$store.state.msg}}</p>
    <button @click="printAction">Print msg</button>
    <button @click="reduceAction">-</button>
  </div>
</template>
<script>
    import { mapActions } from 'vuex' // 引入mapActions
    export default {
        methods: {
          ...mapActions([
              'printAction', // 映射 this.printAction() 为 this.$store.dispatch('printAction')
              'reduceAction'
          ]),
        },
        created() {
    // 通过 store.dispatch 方法触发actions的方法
          this.$store.dispatch('addAction')
          this.$store.dispatch('addStrAction',666)  // 同样支持载荷
        }
    }
</script>
